package com.zhongkun.datahome.service.domain;

import com.zhongkun.datahome.service.constant.YesOrNoEnum;
import com.zhongkun.datahome.service.req.cmd.customer.CustomerBaseCmd;
import com.zhongkun.datahome.service.req.cmd.family.CustomerFamilyCmd;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * 客户基础对象 customer_base
 * 
 * @author ruoyi
 * @date 2025-04-14
 */
@Data
public class CustomerBase extends BaseEntity {
    @ApiModelProperty("客户姓名")
    private String customerName;

    @ApiModelProperty("手机号码")
    private String mobile;

    @ApiModelProperty("用户id")
    private Long userId;

    @ApiModelProperty("商户用户id")
    private Long tenantUserId;

    @ApiModelProperty("是否业主，0否，1是")
    private Integer isOwner;

    @ApiModelProperty("与业主关系")
    private String relation;

    @ApiModelProperty("所属家庭id")
    private Long familyId;

    public static CustomerBase of(CustomerBaseCmd cmd) {
        CustomerBase customerBase = new CustomerBase();
        customerBase.setCustomerName(cmd.getCustomerName());
        customerBase.setMobile(cmd.getMobile());
        // customerBase.setUserId(cmd.getUserId());
        // customerBase.setTenantUserId(cmd.getTenantUserId());
        // customerBase.setIsOwner(cmd.getIsOwner());
        // customerBase.setRelation(cmd.getRelation());
        // customerBase.setFamilyId(cmd.getFamilyId());

        return customerBase;
    }

    public static CustomerBase ofMember(CustomerFamilyCmd cmd) {
        CustomerBase customerBase = new CustomerBase();
        customerBase.updateMember(cmd);
        customerBase.setIsOwner(YesOrNoEnum.NO.getCode());
        customerBase.setFamilyId(cmd.getFamilyId());

        return customerBase;
    }

    public void updateMember(CustomerFamilyCmd cmd) {
        this.setCustomerName(cmd.getCustomerName());
        this.setMobile(cmd.getMobile());
        this.setRelation(cmd.getRelation());
    }
}
